package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.constant.SymbolConsts;
import com.iwhalecloud.bss.kite.common.util.KiteObjectUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.IncrementServiceAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@AttrHandler(IncrementServiceAttrHandler.class)
public class IncrementServiceAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Override
    public void handle(KiteAttr kiteAttr, KiteInst inst, AttrData attrData) {
        // 人工增值服务包  对应的属性下拉框必填
        String[] values = KiteStringUtils.split(inst.getAttrValue("210004140"), SymbolConsts.COMMA);
        KiteAttr speedAttr1 = inst.getAttr("200003809");
        if (!KiteObjectUtils.isEmpty(speedAttr1)) {
            if (KiteStringUtils.equalsAny("110007160", values)) {
                speedAttr1.setIsNull(KeyConsts.IFTRUE_F);
                speedAttr1.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_D);
            } else {
                LocalAttrHelper.hiddenOrDisplayProdAttr(attrData.getSceneInstId(), inst, speedAttr1, KeyConsts.PROD_ATTR_SHOW_TYPE_H, "");
            }
        }
        KiteAttr speedAttr2 = inst.getAttr("210004139");
        if (!KiteObjectUtils.isEmpty(speedAttr2)) {
            if (KiteStringUtils.equalsAny("110007161", values)) {
                speedAttr2.setIsNull(KeyConsts.IFTRUE_F);
                speedAttr2.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_D);
            } else {
                LocalAttrHelper.hiddenOrDisplayProdAttr(attrData.getSceneInstId(), inst, speedAttr2, KeyConsts.PROD_ATTR_SHOW_TYPE_H, "");
            }
        }
    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
